import Packet from "../net/Packet"

// 服务器时间
export default class SystemTime {
	/**
	 * @param time
	 */
	public constructor(public time: number) { }

	public encode(): Packet {
		const packet = this._encode()
		packet.Encode(1010)
		return packet
	}

	public encodeMsg(): ByteBuffer {
		return this._encode().GetBuffer()
	}

	public static decode(packet: Packet): SystemTime {
		const time = packet.ReadUint()
		return new SystemTime(time)
	}

	private _encode(): Packet {
		const packet = new Packet()
		packet.WriteUint(this.time)
		return packet
	}
}
